package dfa;

import java.util.Set;

/**
 * @author haoly
 * @title DFADesign
 * @date 2025/4/16 12:30
 * @description DFADesign
 */
public class DFADesign<T> {

    private final T startState;

    private final Set<T> acceptStates;

    private final  DFARulebook<T> rulebook;

    public DFADesign(T startState, Set<T> acceptStates, DFARulebook<T> rulebook) {
        this.startState = startState;
        this.acceptStates = acceptStates;
        this.rulebook = rulebook;
    }

    public DFA<T> toDFA(){
        return new DFA<>(this.startState, this.acceptStates, this.rulebook);
    }

    public Boolean accepts(String s){
        DFA<T> dfa = toDFA();
        dfa.readString(s);
        return dfa.accepting();
    }

    public T getStartState() {
        return startState;
    }

    public Set<T> getAcceptStates() {
        return acceptStates;
    }

    public DFARulebook<T> getRulebook() {
        return rulebook;
    }
}
